#coding=utf-8
import re
from django.db import models

class User(models.Model):
  user_id = models.CharField(max_length=25, unique=True)
  
  name = models.CharField(max_length=100, blank=True, null=True)
  address = models.CharField(max_length=200, blank=True, null=True)
  des = models.CharField(max_length=500, blank=True, null=True)
  email = models.EmailField(blank=True, null=True)
  
  def __unicode__(self):
    if self.name:
      return self.name
    return self.user_id
    
class Message(models.Model):
  user = models.ForeignKey('User')
  
  resource_id = models.CharField(max_length=25)
  content = models.TextField()
  published_at = models.DateTimeField()
  
  created_at = models.DateTimeField(auto_now_add=True)
  
  def __unicode__(self):
    return re.sub(r'<.*>', '', self.content)

  
